import { Controller, Get, Inject, Query, HttpStatus } from '@nestjs/common';
import { StatisticService } from './statistic.service';
import {
  ApiTags,
  ApiOperation,
  ApiBearerAuth,
  ApiResponse,
} from '@nestjs/swagger';
import {
  RequireLogin,
  RequirePermission,
} from 'src/middleware/RBAC/custom.decorator';
import { PublicVoError } from '../utils/publicVo/index';
import { MeetingCountVo } from './vo/meeting-count.vo';
import { UserCountVo } from './vo/user-count.vo';

@ApiTags('统计管理模块')
@Controller('statistic')
export class StatisticController {
  @Inject(StatisticService)
  private statisticService: StatisticService;

  @Get('meetingCount')
  @ApiOperation({
    summary: '会议室使用统计',
    description: '会议室使用统计接口',
  })
  @ApiBearerAuth()
  @RequireLogin()
  @RequirePermission()
  @ApiResponse({
    status: HttpStatus.OK,
    description: '请求成功',
    type: MeetingCountVo,
  })
  @ApiResponse({
    status: HttpStatus.BAD_REQUEST,
    description: '请求失败',
    type: PublicVoError,
  })
  async userBookignCount(
    @Query('startTime') startTime: string,
    @Query('endTime') endTime: string,
  ) {
    return this.statisticService.userBookingCount(startTime, endTime);
  }

  @Get('userCount')
  @ApiOperation({ summary: '用户预约统计', description: '用户预约统计接口' })
  @ApiBearerAuth()
  @RequireLogin()
  @RequirePermission()
  @ApiResponse({
    status: HttpStatus.OK,
    description: '请求成功',
    type: UserCountVo,
  })
  @ApiResponse({
    status: HttpStatus.BAD_REQUEST,
    description: '请求失败',
    type: PublicVoError,
  })
  async meetingRoomUsedCount(
    @Query('startTime') startTime: string,
    @Query('endTime') endTime: string,
  ) {
    return this.statisticService.meetingRoomUsedCount(startTime, endTime);
  }
}
